from rest_framework import serializers
from .models import CouponTypeValue,CouponType,Coupon,GetCoupon

class TypeSer(serializers.ModelSerializer):
    class Meta:
        model = CouponType
        fields = '__all__'

class ValueSer(serializers.ModelSerializer):
    class Meta:
        model = CouponTypeValue
        fields = '__all__'


class CouPonSer(serializers.ModelSerializer):
    goods_name = serializers.SerializerMethodField(read_only=True)
    def get_goods_name(self,obj):
        return obj.good.name
    class Meta:
        model = Coupon
        fields = '__all__'

class GetSer(serializers.ModelSerializer):
    class Meta:
        model = GetCoupon
        fields = '__all__'


